	//加载配置信息
	
	//统计图
	$(function(){
		var warningImg = echarts.init(echartsDom);
		window.onresize = function(){
			warningImg.resize();
		};
		warningImg.setOption(option);
	});
	var echartsDom = document.getElementById('warning-body');
	var option = {
		color: ['#3398DB'],
		tooltip : {
			trigger: 'axis',
			axisPointer : {            // 坐标轴指示器，坐标轴触发有效
				type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
			}
		},
		legend: {
			width: '100%'
		},
		grid: {
			top: '5%',
			left: '2%',
			right: '2%',
			bottom: '0',
			containLabel: true
		},
		xAxis : [
			{
				type : 'category',
				data : ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
				axisTick: {
					alignWithLabel: true
				}
			}
		],
		yAxis : [
			{
				type : 'value'
			}
		],
		series : [
			{
				name:'安全预警数量',
				type:'bar',
				barWidth: '60%',
				data:[10, 52, 200, 334, 390, 330, 220]
			}
		]
	};

	//新闻提示栏
	$.ajax({
		url: contextPath + "/mainpageitem/testNewsCard",
		type: "get",
		cache: false,
		data: {},
		dataType: "json",
		success: function(d){
			var _dataH = d.data,
				_dataB = null;
				lenH = d.cardCount,
				lenB = 0;
				_newsHead = "",
				_newsBody = "";
			for (var i = 0; i < lenH; i++) {
				_newsHead += '<li data-page="' + i + '"><p>' + _dataH[i].name + '</p></li>';
				_dataB = _dataH[i].news;
				_newsBody = '<ul class="news-body" data-page="' + i + '">';
				for (var j = 0, lenB = _dataH[i].count; j < lenB && j < 4; j++) {
					_newsBody += '<li><a href="' + _dataB[j].url + '" target="_blank"><span>' + _dataB[j].time + '</span>' + _dataB[j].title + '</a></li>';
				}
				_newsBody += '<p class="news-more"><a href="' + _dataH[i].moreUrl + '" target="_blank">更多</a></p></ul>';
				$(".news-tap").append(_newsBody);
			}
			$(".news-head").html(_newsHead);
			//新闻提示栏切换
			$(".news-head").on("click","li",function(){
				$(this).addClass("onClick").siblings().removeClass("onClick");
				$(".news-body[data-page='" + $(this).attr("data-page") + "'").addClass("block").siblings().removeClass("block");
			});
			$(".news-head>li:first").trigger("click");
		},
		error: function(data){
			console.log(data);
		}});
	//数字统计卡

	$.ajax({
		url: contextPath + "/mainpageitem/testNumberCard",
		type: "get",
		cache: false,
		data: {},
		dataType: "json",
		success: function(d){
			var _data = d.data,
				str = "";
				$(".todo-head").text(d.name);
				$(".todo-more").prop("href",d.moreUrl);
			for (var i = 0; i < 3; i++) {
				str += '<li><a href="' + _data[i].url + '" target="_blank">' + _data[i].name + '<span class="' + (_data[i].count?"todo-num":"") + '">' + _data[i].count + '</span></a></li>';
			}
			$(".todo-body").html(str);
		},
		error: function(data){
			console.log(data);
		}});

	//加载子系统列表
	$.ajax({
		url: contextPath + "/SubSystem/querySubSystem",
		type: "get",
		cache: false,
		data: {
			page: 1,
			size: 1000,
			order: "",
			orderBy: "",
			sysName: ""
		},
		dataType: "json",
		success: function(data){
			if(data.code == "2"){
				$(".subsystem-body").html(data.message);
				return ;
			}
			var _str = "";
			for(var i = 0; i < data.length; i++){
				_str += '<div class="system">'+
			                '<h3>'+ data[i].name +'</h3>'+
			                '<div class="clearfix">'+
			                    '<img src="' + contextPath + '/images/subsystem/'+ data[i].icourl +'.png">'+
			                    '<div>';
				switch(data[i].status){
				 case 0:
					 _str += '<p>状态:<span class="offLine">离线</span></p>';
					 break;
				 case 1:
					 _str += '<p>状态:<span class="onLine">运行</span></p>';
					 break;
				 default:
					 _str += '<p>状态:<span class="text-danger">未知</span></p>';
				}	
				_str += '<p>厂商:<span>'+ data[i].vendor +'</span></p>';
				switch(data[i].type){
				 case "0":
					 _str += '<p>类型:<span>子系统</span></p>';
					 break;
				 case "1":
					 _str += '<p>类型:<span>平台</span></p>';
					 break;
				 default:
					 _str += '<p>类型:<span>未知</span></p>';
				}
			    _str += '<p><a class="jump" data-id="'+ data[i].id +'" data-href="'+ data[i].loginUrl +'" data-mainHref="'+ data[i].mainUrl +'">进入系统&nbsp;&gt;&gt;</a></p>'+
			                    '</div>'+
			                '</div>'+
			            '</div>';
			}
//			$(".subsystem-body").html(_str);
			$(".subsystem-body").html('<img style="width: 100%;" src="' + contextPath + '/images/subsystem/linshi2.png"></img>');
			$(".linshi").html('<img style="margin-left: -15px;width: calc(100% + 30px);height: 270px;" src="' + contextPath + '/images/subsystem/linshi.png"></img>');
		    $("a.jump").on("click",function(){
		    	var len = userSubSystem.length;
				for(var i = 0; i < len; i++){
					if(userSubSystem[i].subSystem == $(this).attr("data-id")){
						var str = '<iframe style="display:none;" id="hiddenFrm" name="hiddenFrm"></iframe><form style="display:none;" id="autoForm" action="'+ $(this).attr("data-href") + '" target="hiddenFrm" method="post"><input type="text" id="username" name="username" value="'+ userSubSystem[i].username +'" /><input type="password" id="password" name="password" value="'+ userSubSystem[i].password +'" /></form>';
						str += '<script>var iframe = document.getElementById("hiddenFrm");'+
									'if (iframe.attachEvent){'+
									    'iframe.attachEvent("onload", function(){'+
									    	'window.location.href = "' + $(this).attr("data-mainHref") + '";'+
									    '});'+
									'} else {'+
									    'iframe.onload = function(){'+
									    	'window.location.href = "' + $(this).attr("data-mainHref") + '";'+
									    '};'+
									'};'+
									'document.getElementById("autoForm").submit();'+
								'<\/script>';
						var wd = window.open();
						wd.document.write(str);
						return;
					}
				}
				alert("没有相关权限");
	   		});
		},
		error: function(data){
			console.log(data);
			$("div.subsystem-body").html("加载出错，请检查您的网络!");
		}
	});
